package com.zm.demo.shoppingmall.product.service.impl;

import com.zm.demo.shoppingmall.product.api.ProductService;
import com.zm.demo.shoppingmall.product.dao.TProductMapper;
import com.zm.demo.shoppingmall.product.model.TProduct;
import com.zm.demo.shoppingmall.product.model.TProductCondition;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @desc:
 * @author: z01140
 * @date: 2021/5/24 21:02
 */
@DubboService
public class ProductServiceImpl implements ProductService {

    @Autowired
    private TProductMapper productMapper;

    @Override
    public int addProduct(TProduct tProduct) {
        LocalDateTime now = LocalDateTime.now();
        tProduct.setCreateTime(now);
        tProduct.setUpdateTime(now);
        return productMapper.insertSelective(tProduct);
    }

    @Override
    public int updateProduct(TProduct tProduct) {
        LocalDateTime now = LocalDateTime.now();
        tProduct.setUpdateTime(now);
        return productMapper.updateByPrimaryKeySelective(tProduct);
    }

    @Override
    public int deleteProuctByProductId(Integer productId) {
        return productMapper.deleteByPrimaryKey(productId);
    }

    @Override
    public TProduct getProductByProductNo(String productNo) {
        return productMapper.getProductByProductNo(productNo);
    }

    @Override
    public TProduct getProductById(Integer productId) {
        return null;
    }

    @Override
    public List<TProduct> getProductByCondition(TProductCondition tProductCondition) {
        return null;
    }
}
